<template>
  <div class="search-content">
    <div class="search-list" :class="{ toggleFlag : toggleFlag}">
      <slot></slot>
    </div>
    <div class="search-btn" :class="{toggleFlag: toggleFlag}">
      <!-- <div class="showOrHide" @click="toggleFlag = !toggleFlag">{{ toggleFlag?'展开':'收起' }}</div> -->
      <div v-if="renovate">
        <el-button class="showOrHide" @click="reloads">
          <i class="el-icon-refresh"></i> 刷新
        </el-button>
      </div>
      <div v-if="exportShow">
        <img src="~@/assets/action-bar-icon/export-active.png" @click="outData" />
      </div>
      <div v-if="searchShow">
        <img src="~@/assets/action-bar-icon/search.png" @click="search" />
      </div>
      <div v-if="resetShow">
        <img src="~@/assets/action-bar-icon/rsest.png" @click="reset" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  inject: ["reload"],
  props: {
    renovate: {
      type: Boolean,
      default: true
    },
    exportShow: {
      type: Boolean,
      default: false
    },
    searchShow: {
      type: Boolean,
      default: false
    },
    resetShow: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      toggleFlag: false // false: 展开 true: 收起
    };
  },
  methods: {
    search() {
      this.$emit("search");
    },
    outData() {
      this.$emit("Export");
    },
    reset() {
      this.$emit("reset");
    },
    reloads() {
      this.reload();
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/styles/variables.scss";
.search-content {
  position: relative;
  display: flex;
  justify-content: flex-start;
  color: #404040;
  .search-btn {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: row;
    justify-content: flex-end;
    margin-top: 3px;
    & > div {
      display: flex;
      align-items: center;
      flex-wrap: nowrap;
      flex-direction: row;
      justify-content: flex-end;
      margin-right: 12px;
      cursor: pointer;
      &:hover {
        transform: scale(1.05);
      }
    }
  }
}
::v-deep .showOrHide {
  width: 68px;
  height: 30px;
  background: #1bd46e;
  border-radius: 5px 5px 5px 5px;
  opacity: 1;
  border: 2px solid #07b519;
  padding: 0;
  color: white;
  font-size: 15px;
  > span {
    display: inline-block;
    width: 62px;
    height: 26px;

    background: #1bd46e;
    box-shadow: 0px 0px 2px 1px rgba(0, 0, 0, 0.2);
    border-radius: 3px 3px 3px 3px;
    opacity: 1;
    padding: 4.5px 2px;
    // display: flex;
  }
  // text-align: center;
  // font-size: 16px;
  // top: 15px;
  white-space: nowrap;
  // display: block;
  // right: 93px;
}
.search-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  // width: 100%;
  min-height: 45px;
  justify-content: flex-start;
  align-content: flex-start;
  ::v-deep .common-search-item {
    margin-bottom: 5px;
    margin-top: 5px;
    min-width: 300px;
    max-width: 340px;
    .label {
      width: auto !important;
      min-width: 80px !important;
      text-align: end;
    }
    .input {
      width: 80%;
    }
    // ::v-deep {
    .el-select {
      width: 100%;
    }
    .el-cascader {
      width: 100%;
    }
    .el-date-editor {
      width: 100%;
    }
    // }
  }
  // 时间 长框适用
  ::v-deep .common-search-items {
    margin-bottom: 5px;
    margin-top: 5px;
    width: 43%;
    max-width: 64%;
    .label {
      width: auto !important;
      min-width: 80px !important;
      text-align: end;
    }
    .input {
      width: 80%;
    }
    // ::v-deep {
    .el-select {
      width: 100%;
    }
    .el-cascader {
      width: 100%;
    }
    .el-date-editor {
      width: 100%;
    }
    // }
  }
  ::v-deep .common-search-itemx {
    margin-bottom: 5px;
    margin-top: 5px;
    width: 33%;
    max-width: 64%;
    .label {
      width: auto !important;
      min-width: 80px !important;
      text-align: end;
    }
    .input {
      width: 80%;
    }
    // ::v-deep {
    .el-select {
      width: 100%;
    }
    .el-cascader {
      width: 100%;
    }
    .el-date-editor {
      width: 100%;
    }
    // }
  }
  &.toggleFlag {
    flex-direction: row;
    flex-wrap: nowrap;
    ::v-deep .common-search-item {
      margin-right: 10px;
      &:nth-child(n + 4) {
        margin-top: 10px;
        display: none;
      }
    }
    ::v-deep .common-search-items {
      margin-right: 10px;
      &:nth-child(n + 8) {
        margin-top: 10px;
        display: none;
      }
    }
  }
}
.search-btn {
  // width: 100px;
  flex-shrink: 0;
  margin-left: 20px;
  // display: flex;
  // align-items: center;
  position: relative;
  &.toggleFlag {
    display: flex;
    align-items: center;
    width: 120px;
    .searchBtn {
      margin-top: 0;
      margin-left: 10px;
    }
  }
  .showOrHide {
    cursor: pointer;
    text-align: center;
    font-size: 16px;
    &:hover {
      color: $tagsViewActiveBgColor;
    }
  }
  .searchBtn {
    margin: 0px auto 0;
    position: absolute;
    top: 7px;
    right: 7px;
    // margin: 10px auto 0;
    img {
      display: block;
      margin: 0 auto;
    }
  }
}
</style>
